package com.vf.activity.service.impl;

import java.util.List;

import com.vf.activity.domain.DTO.ActivitiesDTO;
import com.vf.activity.domain.DTO.ApplicationsDTO;
import com.vf.activity.mapper.ActivityParticipantsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vf.activity.mapper.ActivityApplicationsMapper;
import com.vf.activity.domain.ActivityApplications;
import com.vf.activity.service.IActivityApplicationsService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 活动参与申请Service业务层处理
 * 
 * @author LBS
 * @date 2025-06-04
 */
@Service
public class ActivityApplicationsServiceImpl implements IActivityApplicationsService 
{
    @Autowired
    private ActivityApplicationsMapper activityApplicationsMapper;

    @Autowired
    private ActivityParticipantsMapper activityParticipantsMapper;
    /**
     * 查询活动参与申请
     * 
     * @param applicationId 活动参与申请主键
     * @return 活动参与申请
     */
    @Override
    public ActivityApplications selectActivityApplicationsByApplicationId(Long applicationId)
    {
        return activityApplicationsMapper.selectActivityApplicationsByApplicationId(applicationId);
    }

    /**
     * 查询活动参与申请列表
     * 
     * @param activityApplications 活动参与申请
     * @return 活动参与申请
     */
    @Override
    public List<ActivityApplications> selectActivityApplicationsList(ActivityApplications activityApplications)
    {
        return activityApplicationsMapper.selectActivityApplicationsList(activityApplications);
    }

    /**
     * 新增活动参与申请
     * 
     * @param activityApplications 活动参与申请
     * @return 结果
     */
    @Override
    public int insertActivityApplications(ActivityApplications activityApplications)
    {
        return activityApplicationsMapper.insertActivityApplications(activityApplications);
    }

    /**
     * 修改活动参与申请
     * 
     * @param activityApplications 活动参与申请
     * @return 结果
     */
    @Override
    public int updateActivityApplications(ActivityApplications activityApplications)
    {
        return activityApplicationsMapper.updateActivityApplications(activityApplications);
    }

    /**
     * 批量删除活动参与申请
     * 
     * @param applicationIds 需要删除的活动参与申请主键
     * @return 结果
     */
    @Override
    public int deleteActivityApplicationsByApplicationIds(Long[] applicationIds)
    {
        return activityApplicationsMapper.deleteActivityApplicationsByApplicationIds(applicationIds);
    }

    /**
     * 删除活动参与申请信息
     * 
     * @param applicationId 活动参与申请主键
     * @return 结果
     */
    @Override
    public int deleteActivityApplicationsByApplicationId(Long applicationId)
    {
        return activityApplicationsMapper.deleteActivityApplicationsByApplicationId(applicationId);
    }

    @Override
    public List<ApplicationsDTO> getActivityApplicationsByUserId(Long userId) {
        return activityApplicationsMapper.getActivityApplicationsByUserId(userId);
    }

    @Override
    public List<ActivitiesDTO> getActivityByUserId(Long userId) {
        return activityApplicationsMapper.getActivityByUserId(userId);
    }

    @Override
    public List<ApplicationsDTO> getActivityJoinByUserId(Long userId) {
        return activityApplicationsMapper.getActivityJoinByUserId(userId);
    }

    @Override
    public List<ApplicationsDTO> getActivityPByUserId(Long userId) {
        return activityApplicationsMapper.getActivityPByUserId(userId);
    }

    @Override
    @Transactional
    public int updateActivityApplicationsPass(Long applicationId) {
        int i = activityApplicationsMapper.updateActivityApplicationsPass(applicationId);
        int j =activityParticipantsMapper.insertActivityParticipant(applicationId);
        if (i>0 && j>0){
            return 1;
        }
        return 0;
    }

    @Override
    public int updateActivityApplicationsNoPass(Long applicationId) {
        return activityApplicationsMapper.updateActivityApplicationsNoPass(applicationId);
    }
}
